﻿using System.Data.Entity;
using Quba.Entities.Database.Question;
using Quba.Entities.Database.Tag;
using Quba.Entities.Database.User;

namespace Quba.Framework.Database
{
    public class QubaContext : DbContext
    {
        public QubaContext()
            : base("name=QubaContext")
        {
            
        }

        public DbSet<Admin> Admins { get; set; }
        public DbSet<Candidate> Candidates { get; set; } 
        public DbSet<Question> Questions { get; set; } 
        public DbSet<Option> Options { get; set; } 
        public DbSet<QuestionPaper> QuestionPapers { get; set; }
        public DbSet<QuestionType> QuestionTypes { get; set; } 
        public DbSet<Tag> Tags { get; set; } 
        public DbSet<AnswerPaper> AnswerPapers { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            // TODO: Perform any fluent API configuration here!

            modelBuilder.Entity<QuestionPaper>()
                .HasMany(x => x.Questions)
                .WithMany()
                .Map(x => x.ToTable("QuestionPaperMapping"));
        }
    }
}
